/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ttt.nor2.smssender;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;

/**
 *
 * @author anuphabm
 */
public class LoadClient {

    public static HttpClient getClient(ConfigHttp conf){

        MultiThreadedHttpConnectionManager cm = new MultiThreadedHttpConnectionManager();
        HttpConnectionManagerParams cp = new  HttpConnectionManagerParams();

        cp.setDefaultMaxConnectionsPerHost(conf.getMaxConn());
        cp.setMaxTotalConnections(conf.getMaxTConn());
        cp.setSoTimeout(conf.getTimeout());
        cp.setConnectionTimeout(conf.getTimeout());
        cm.setParams(cp);
        cm.closeIdleConnections(conf.getTimeout());
        //
        HttpClient ct = new HttpClient(cm);
        return ct;
    }

}
